package com.zgjkhis.modules.charges.service.mapper;

import com.zgjkhis.common.mapper.CoreMapper;
import com.zgjkhis.modules.charges.domain.Invoice;
import com.zgjkhis.modules.charges.service.dto.InvoiceQueryCriteria;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author yzq
 * @Description 发票打印
 * @Date 2021/6/23 9:48
 * @Param
 * @return
 **/
@Repository
public interface InvoiceMapper extends CoreMapper<Invoice> {


    @Select("<script>select * from his_invoice t\n" +
            "where 1=1 and t.pharmacy_id=#{invoice.pharmacyId}\n" +
            "<if test=\"invoice.startTime !=null \"> \n" +
            "   and t.create_time  &gt; #{invoice.startTime}\n" +
            "</if>\n" +
            "<if test=\"invoice.endTime !=null \">\n" +
            "   and t.create_time    &lt;  str_to_date(DATE_ADD(#{invoice.endTime},INTERVAL 1 DAY), '%Y-%m-%d %H')\n" +
            "</if>\n" +
            "<if test=\"invoice.username !=null\">\n" +
            "  and t.username LIKE CONCAT('%',#{invoice.username},'%')\n" +
            "</if></script>")
    List<Invoice> findAllByPageable(@Param("invoice") InvoiceQueryCriteria criteria);
}
